using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using SCS.Common.Models;
namespace SCS.DAL.Mapping
{
    public class TermMap : EntityTypeConfiguration<Term>
    {
        public TermMap()
        {
            // Primary Key
            this.HasKey(t => t.termID);

            // Properties
            this.Property(t => t.termID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.termName)
                .IsRequired()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("Term");
            this.Property(t => t.termID).HasColumnName("termID");
            this.Property(t => t.termName).HasColumnName("termName");
            this.Property(t => t.schoolYearID).HasColumnName("schoolYearID");

            // Relationships
            this.HasRequired(t => t.SchoolYear)
                .WithMany(t => t.Terms)
                .HasForeignKey(d => d.schoolYearID);

        }
    }
}
